  // 7. 使用reduce实现[1,2,3,4,9]数组中所有成员的和
  const arr7 = [1, 2, 3, 4, 9];
  const sum7 = arr7.reduce(function (accumulator, current) {
    return accumulator + current;
  }, 0);
  console.log(sum7);
  // 8. 数组去重的方法 (4种)
  //
  let arr8 = [1, 2, 3, 1, 5, 8, 7, 2, 5, 6, 4, 2];
  // 1.forEach
  let newArray8 = [];
  arr8.forEach(function (ele, index) {
    if (!newArray8.includes(ele)) {
      newArray8.push(ele);
    }
  });
  console.log(newArray8);

  // 2.filter,但是不是按照顺序输出，对应的数字只会取最后一次出现的位置
  let newArray82 = [];
  newArray82 = arr8.filter(function (ele, index, arr) {
    if (!arr.includes(ele, index + 1)) {
      return ele;
    }
  });
  console.log(newArray82);
  // 3.map和filter连用，但是也不会按顺序输出，对应的数字只会取最后一次出现的位置
  let newArray83 = [];
  newArray83 = arr8
    .map(function (ele, index, arr) {
      if (!arr.includes(ele, index + 1)) {
        return ele;
      }
    })
    .filter(function (ele) {
      if (ele !== "indefined") {
        return ele;
      }
    });
  console.log(newArray83);
  // 4.reduce
  let newArray84 = [];
  newArray84 = arr8.reduce(function (total, current) {
    if (!total.includes(current)) {
      total.push(current);
    }
    return total;
  }, []);
  console.log(newArray84);